home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / NODEPROC.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  36KB  |  925 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*               This module was written by Vince Perriello                 */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                 BinkleyTerm Nodelist processing module                   */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. char far *get_size (unsigned int);
  51. int get_new_info (unsigned);
  52.  
  53. #ifdef OLDTBBSLIST
  54. int get_TBBS_info (unsigned, ADDR *);
  55. #endif
  56.  
  57. #ifdef V5_LIST
  58. int get_old_info (unsigned);
  59. #endif
  60.  
  61. static off_t  index_filesize = (off_t)  0L;
  62. static time_t index_filetime = (time_t) 0L;
  63. static char   index_filename[80];
  64.  
  65. static unsigned int idx_size = 0;                       /* number of entries  */
  66. static int extra_bytes = 0;
  67. static char *curr_domain = NULL;
  68.  
  69. void get_nodelist_name (ADDR *);
  70.  
  71. void get_nodelist_name (ADDRP opus_addr)
  72. {
  73.     int i;
  74.  
  75.     curr_domain = opus_addr->Domain;
  76.  
  77.     idx_size = 0;
  78.     extra_bytes = 0;
  79.     nodelist_base = nodelist_name;
  80.     for (i = 0; domain_name[i] != NULL; i++)
  81.         {
  82.         if (domain_name[i] == opus_addr->Domain)
  83.             {
  84.             nodelist_base = domain_nodelist[i];
  85.             if (nodelist_base == NULL)
  86.                 nodelist_base = nodelist_name;
  87.             }
  88.         }
  89. }
  90.  
  91. char far *get_size (unsigned int n)
  92. {
  93.     /* If we get this far, then we have to use a straight far pointer */
  94.     return (_fmalloc(n));
  95. }
  96.  
  97. /*---------------------------------------------------------------------------*/
  98. /* CHECKLIST                                                                 */
  99. /* See if nodelist has changed since we first tried to use it and if so,     */
  100. /* dismiss old copy and get a new one                                        */
  101. /*---------------------------------------------------------------------------*/
  102.  
  103. int checklist ()
  104. {
  105.     struct stat idxstat;
  106.     if (index_filesize == (off_t)0L)
  107.         return (0);
  108.     (void) stat (index_filename, &idxstat);    
  109.     if ((index_filesize == idxstat.st_size) && (index_filetime == idxstat.st_mtime)) 
  110.         return (0);
  111.     status_line (MSG_TXT(M_REFRESH_NODELIST));
  112.     _ffree( node_index );
  113.     node_index = (char far *) NULL;
  114.     index_filesize = (off_t)0L;
  115.     return (1);
  116. }
  117.  
  118.  
  119. /*---------------------------------------------------------------------------*/
  120. /* NODEPROC                                                                  */
  121. /* Find nodelist entry and set baud to nodelist baud for dialing out         */
  122. /*---------------------------------------------------------------------------*/
  123.  
  124. int nodeproc (char *nodeaddr)
  125. {
  126.     ADDR opus_addr;
  127.     char *c;
  128.  
  129.     c = skip_blanks (nodeaddr);                     /* get rid of the blanks  */
  130.     if (!find_address (c, &opus_addr))
  131.         {
  132.         return (0);
  133.         }
  134.     if (!nodefind (&opus_addr, 1))              /* if we can't find the node  */
  135.         return (0);                             /* go away now                */
  136.     status_line (MSG_TXT(M_PROCESSING_NODE), Full_Addr_Str (&opus_addr), newnodedes.SystemName);
  137.     if (!CARRIER)                               /* if no carrier yet,         */
  138.         {
  139.         if (autobaud)
  140.             (void) set_baud (max_baud.rate_value, 1);   /* Set to highest rate*/
  141.         else
  142.             (void) set_baud ((300 * newnodedes.BaudRate), 1);/* nodelist baud */
  143.         }
  144.     return (1);                                 /* return success to caller   */
  145. }
  146.  
  147. /*---------------------------------------------------------------------------*/
  148. /* NODEFIND                                                                  */
  149. /* Find nodelist entry for use by other routines (password, nodeproc)        */
  150. /* If found, result will be in "newnodedes".                                 */
  151. /*---------------------------------------------------------------------------*/
  152.  
  153. int nodefind (ADDRP bink_addr, int prtflag)
  154. {
  155.     int i, j, k;
  156.     int have_boss_data = 0;
  157.     int need_boss_data = 0;
  158.  
  159.     (void) checklist ();
  160.  
  161.     newnodedes.NetNumber = newnodedes.NodeNumber = found_zone = found_net = 0;
  162.  
  163.     CURRENT = DEFAULT;                          /* Set default paths, quotas  */
  164.  
  165.     if ((bink_addr->Net == boss_addr.Net) 
  166.     &&  (bink_addr->Node == boss_addr.Node) 
  167.     &&  (bink_addr->Zone == alias[0].Zone) 
  168.     &&  ((bink_addr->Domain == boss_addr.Domain) || (bink_addr->Domain == NULL)))
  169.         {
  170.         ++need_boss_data;
  171.         if (BOSSphone && strlen (BOSSphone) > 2)
  172.             ++have_boss_data;
  173.         if (BOSSpwd && strlen (BOSSpwd) > 2)
  174.             ++have_boss_data;
  175.         }
  176.  
  177.     if (!bink_addr->Zone)
  178.         {
  179.         bink_addr->Zone = alias[0].Zone;
  180.         i = (*nodefunc) (bink_addr, have_boss_data);
  181.         if (i) goto lookup_done;
  182.         }
  183.     i = (*nodefunc) (bink_addr, have_boss_data);
  184.  
  185. lookup_done:
  186.  
  187.     assum